package com.xiaochen.baidu.common.design.link;

import java.util.LinkedList;

/**
 * @author xc
 * @date 2025/10/11/22:09
 * @desc
 */
public class BusinessLinkedList <T,D,R> extends LinkedList<ILogicHandler<T,D,R>> implements ILogicHandler<T,D,R>{

    @Override
    public R handle(T requestParameter, D dynamicContext) throws Exception {
        int size = this.size();
        int index = 0;
        ILogicHandler<T, D, R> current = get(index++);
        do{
            R handle = current.handle(requestParameter, dynamicContext);
            if(null != handle){
                return handle;
            }
            current = get(index++);
        }while (null != current);
        return null;
    }
}
